package acm;

import java.util.Scanner;

public class 审美课 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int m=in.nextInt();
        int sum=0,j,count=0;
        String s="";
        String[][] a = new String[n][];
        for (int i=0;i<n;i++)
        {
        for ( j=0;j<m;j++)
        {
                a[i][j]=in.next();
        }
        }
        for (int i=0;i<n;i++){
            for (j=0;j<m-1;j++){
                if (a[count][j].equals(a[i+1][j])){
                    break;
                }
            }
            if (j==m-1){
                sum++;
            }
        }
        System.out.print(sum);
    }
}
